<template>
	<view class='product-bg'>
		<swiper :indicator-dots="indicatorDots" indicator-color="#fff"  indicator-active-color="#e93323" :circular="circular"
		 :interval="interval" :duration="duration" :style="'height:'+(imageH)+'rpx;'" @change="change">	 
			<block v-for="(item,index) in imgUrls" :key='index'>
				<swiper-item>
					<image :src="item" class="slide-image" @click='getpreviewImage(item)' mode="widthFix" />
				</swiper-item>
			</block>
		</swiper>
		<view class="swiper-images-number acea-row row-middle row-center">
			{{currents}}/{{imgUrls.length}}
		</view>
	</view>
</template>
<script>

	export default {
		props: {
			imgUrls: {
				type: Array,
				default: function() {
					return [];
				}
			},
			videoline: {
				type: String,
				value: ""
			},
			isType: {
				type: Number,
				default: 1
			}
		},
		data() {
			return {
				currents: 1,
				indicatorDots: true,
				circular: true,
				autoplay: true,
				interval: 5000,
				duration: 500,
				controls: true,
				imageH: ""
			};
		},
		created() {
		},
		watch: {

		},
		mounted() {
			let that = this
			that.$nextTick(function() {
				uni.getImageInfo({
					src: that.setDomain(that.imgUrls[0]),
					success: function(res) {
						if (res && res.height > 0) {	
							let height = res.height * ((750-40) / res.width)
							that.$set(that, 'imageH', height);	
						} else {
							that.$set(that, 'imageH', 710);
						}
					},
					fail: function(error) {
						that.$set(that, 'imageH', 375);
					}
				})
			})
		},
		methods: {
			getpreviewImage: function(item) {
				uni.previewImage({
					urls: this.imgUrls,
					current: item
				});
			},
			//替换安全域名
			setDomain: function(url) {
				url = url ? url.toString() : '';
				//本地调试打开,生产请注销
				if (url.indexOf("https://") > -1) return url;
				else return url.replace('http://', 'https://');
			},
			change: function(e) {
				this.$set(this, 'currents', e.detail.current + 1);
			},
		}
	}
</script>

<style scoped lang="scss">
	.product-bg {
		width: 710rpx;
		position: relative;
	}
	.swiper-images-number {
		width: 60rpx;
		height: 41rpx;
		position: absolute;
		background: rgba(40, 40, 40, .5);
		top: 20rpx;
		right: 20rpx;
		border-radius: 22rpx;
		font-size: 20rpx;
		color: #fff;
		z-index: 10;
	}
	.product-bg swiper {
		width: 100%;
		position: relative;
	}
	.product-bg .slide-image {
		width: 100%;
		height: 100%;
		border-radius: 24rpx;
	}
	.product-bg .pages {
		position: absolute;
		background-color: #fff;
		height: 34rpx;
		padding: 0 10rpx;
		border-radius: 3rpx;
		right: 30rpx;
		bottom: 30rpx;
		line-height: 34rpx;
		font-size: 24rpx;
		color: #050505;
	}
	#myVideo {
		width: 100%;
		height: 100%
	}
	.product-bg .item {
		position: relative;
		width: 100%;
		height: 100%;
	}
	.product-bg .item .poster {
		position: absolute;
		top: 0;
		left: 0;
		height: 750rpx;
		width: 100%;
		z-index: 9;
	}
	.product-bg .item .poster .image {
		width: 100%;
		height: 100%;
	}
	.product-bg .item .stop {
		position: absolute;
		top: 50%;
		left: 50%;
		width: 136rpx;
		height: 136rpx;
		margin-top: -68rpx;
		margin-left: -68rpx;
		z-index: 9;
	}
	.product-bg .item .stop .image {
		width: 100%;
		height: 100%;
	}
</style>
